package dexter.testing;

import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.List;
import java.util.Vector;

public class Logger implements Serializable{

	public static final int ERROR = 0;
	public static final int DEGUB = 1;
	public static final int INFO = 2;

	
	private static final long serialVersionUID = 6749016121169845783L;
	
	protected List<String> log=new Vector<String>();

	public void log(String promtp, String info){
		log.add(promtp+info);
	}
	
	public void error(String promtp, Exception e) { 
	    StringWriter sw = new StringWriter(); 
	    PrintWriter pw = new PrintWriter(sw);
	    e.printStackTrace(pw); 
	    log.add(promtp+sw.toString()); 
	    
	}
	
	public void printLog(){		
		for(int i=0; i<log.size(); i++){
			System.out.println(log.get(i));
		}
	}
	
	public String toString(){		
		String s = "";
		for(int i=0; i<log.size(); i++){
			s+=log.get(i)+"\n";
		}
		
		return s;
	}
	
	public void merge(Logger l){
		log.addAll(l.log);
	}
	
	
}
